<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" href="./lib/layui-v2.1.6/layui/css/layui.css">
<link href="./resources/css/login.css" rel='stylesheet' type='text/css'>

<body id="mainBody">
<div class="left"></div>
<div class="right">
	<div class="login-form">
	    <div class="topRegister">
	        <p>Login</p>
	    </div>
	    <div class="Registerform">
	    	<form>
	            <input type="text" class="text" placeholder="请输入账号">
	            <input type="password" placeholder="请输入密码">
	        </form>
	    </div>
	    <div class="signin">
	        <input type="submit" value="登录" >
	    </div>
	</div>
</div>
</body>
<script type="text/javascript" src="./lib/jquery.min.js"></script>
<script type="text/javascript" src="./lib/layui-v2.1.6/layui/layui.js"></script>
<script>
	$('.left').fadeIn(1000);
	$(document).keyup(function(event){
		if(event.keyCode == 13){	//输入回车键时触发事件
			$('input[type="submit"]').click();
		}
	});
    layui.use('layer',function (){
    	var $ = layui.jquery;
        $('input[type="submit"]').click(function () {
            var username=$('input[type="text"]').val();
            var password=$('input[type="password"]').val();
            if(username==""||password==""){
                layer.msg("用户名或密码不能为空");
            }else{
                var param = {
                    account : username,
                    pwd : password,
                };
                $.ajax({
                    url : "./loginController/login",
                    type : "POST",
                    data : param,
                    success : function(response){
                        if(response.code == 200) {
                            //console.log(response.result.permission);
                            localStorage.setItem("loginUser",JSON.stringify(response.result));
                            window.location.href="./index.jsp";
                        }else {
                            layer.msg("用户名或密码错误");
                        }
                    }
                });
            }
        });
    });
</script>
</html>